<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/vue@next"></script>
  <style>
  </style>
</head>
<body>
  <div id="app">
    <h3>渲染函数</h3>
    <h3>渲染函数</h3>
    <anchored-heading :level="3">
      <a href="#hello1" name="hello1">Hello1 Render</a>
    </anchored-heading>
    <h3>渲染函数</h3>
    <anchored-heading :level="2">
      <a href="#hello" name="hello">Hello Render</a>
    </anchored-heading>
    <h3>渲染函数</h3>
  </div>

  <script>
    const app = Vue.createApp({
      
    })
    
    app.component('anchored-heading', {
      props: {
        level: {
          type: Number,
          required: true
        }
      },
      render() {
        const { h } = Vue

        return h(
          'h' + this.level, // tag name
          {}, // props/attributes
          this.$slots.default() // array of children
        )
      }
    })

    app.mount('#app')
  </script>
</body>
</html>